package com.cloud.clouduser.controller;

import com.cloud.cloudcommons.pojo.CommonResult;
import com.cloud.cloudcommons.utils.CommonDateUtil;
import com.cloud.cloudcommons.utils.CommonIdMaker;
import com.cloud.clouduser.pojo.TbUser;
import com.cloud.clouduser.service.UserService;
import com.netflix.discovery.converters.Auto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * @Aurher: QiaoHang
 * @Description:
 * @Data: 2019/9/20 14:39
 * @Modified By:
 */
@RestController
@RequestMapping("/user")
public class PlatController {

    @Autowired
    UserService userService;

    @RequestMapping("/hi")
    public String hi(){
        return "user hi ";
    }

    @RequestMapping(value = "/selectUsersByConditions.do",method = RequestMethod.GET)
    public List<TbUser> selectUsersByConditions(Map<String, Object> map){
        HashMap<String, Object> map1 = new HashMap<>();
        map1.put("create_time",new Object[]{null,"2019-09-21 04:25:11"});
        map1.put("user_id","18814a13085747929ac668cfd7f077bd");
        map1.put("name","6");
        return userService.findUsersByConditions(map1);
    }


    @RequestMapping("/insert.do")
    public CommonResult insert(TbUser tbUser){
        ArrayList<TbUser> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            TbUser user = new TbUser();
            user.setCreate_time(CommonDateUtil.dateFormat.format(new Date()));
            user.setName("乔航"+(i+1));
            user.setPassword("00012");
            user.setPhone("17611660918");
            user.setUser_id(UUID.randomUUID().toString().replace("-",""));
            list.add(user);
        }
        int result = userService.insert(list);
        return CommonResult.SUCCESS;
    }



}
